import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { AppService } from './app.service';
import { TestService } from './test.service';

/**
 * Param ：方法需要调用，用于get请求 接收拼接的参数
 * Query ：方法需要调用，用于post 请求在路径后取出传递的参数值
 * Body  ：方法需要调用，用于post请求，接收数据体的数据
 */

export interface IPramas {
  id:string
  subId?:number
}

@Controller()
export class AppController {
  constructor(
    private readonly appService: AppService,
    private readonly testSerivice:TestService
  ) {}
  @Get()
  getHelloWorld() {
    return this.appService.getHello()
  }

  @Get('/list')
  getList():string {
    return this.testSerivice.getAllData()
  } 

  @Get('/detail/:id/:subId')
  getDetailInfo(@Param() params:IPramas) {
    return this.testSerivice.getDeatilData(params)
  }


  @Post('/add')
  addData(@Body() body, @Query() query:IPramas): string {
    return this.testSerivice.getAddData(body,query)
  }

  @Post('/update')
  updateData(@Body() body, @Query() query:IPramas): string {
    return this.testSerivice.getUpdateData(body,query)
  }

  @Post('/delete')
  deleteData(@Body() body): string {
    return this.testSerivice.getDeleteData(body)
    
  }
}
